<template>
	<view class="container">
		<top-back-navbar position="fixed" title="钱包-可用资金" background="#001b4d" color="#ffff"></top-back-navbar>
		<view class="big_title f-w-700">资产数据</view>
		<view class="cz-box">
			<view class="cz-number">¥{{userInfo.credit2 || '0.00'}}</view> 
			<view class="cz-text">可用资金</view>
		</view>
        <view>
            <block v-for="(item,index) in res" :key="index">
                <view class="cz-list-cell" hover-class="uni-list-cell-hover">
                    <view class="cz-triplex-list">
                        <text class="cz-name">{{item.pay_info}}</text>
                        <text class="cz-jine">¥{{item.money}}</text>
                    </view>
                    <view class="cz-triplex-list">
						<text class="cz-time">{{item.time}}</text>
						<text class="cz-num">{{item.charge_status}}</text>
                    </view>
                </view>
            </block>
        </view>
		<view v-if="res.length == 0" style="padding-top: 300upx;">
			<image src="/static/searchlist.png" mode="" style="display: block;margin: 0 auto;width: 240upx;height: 240upx;"></image>
			<view style="text-align: center;color: #999;">暂时没有任何记录</view>
		</view>
		<!-- <uni-load-more v-if="load == 1" :loadingType="loadingType" :contentText="contentText"></uni-load-more> -->
	</view>
</template>

<script>
	import uniLoadMore from '../../../../components/uni-load-more.vue'
	export default {
		components: {uniLoadMore},
		data() {
			return {
				res:[],
				cointitle:' ',
				index:2,
				loadingType:0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多了"
				},
				systemInfo: {},
				load: 0,
				openid:'',
				userInfo:''
			};
		},
		onLoad:function(e){
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
					this.creditAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		methods:{
			creditAjax(){
				uni.request({
				  url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member&app=1',
				  method: 'POST',
				  data: {
				    'openid': this.openid
				  },
				  header: {
				    'Content-Type': 'application/x-www-form-urlencoded'
				  },
				  success: res => {
				    this.userInfo = res.data
				  },
				  fail: () => {},
				  complete: () => {}
				});
			},
			setAjax(){
				var data = {
				    'openid':this.openid,
				   }
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=order.luckdraw.recharge_list&app=1',
					method: 'POST',
					data: data,
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						this.res = res.data.list
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		onPullDownRefresh() {
			this.setAjax();
		},
		onReachBottom(){
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;
			uni.request({
				url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.log.get_list&app=1&page='+this.index,
				method: 'POST',
				data: {'openid':this.openid},
				header:{'Content-Type':'application/x-www-form-urlencoded'},
				success: res => {
					if(res.data.result.list.length == 0){
						this.loadingType = 2;
						return;
					}
					this.res = this.res.concat(res.data.result.list)
					this.loadingType = 0;
					this.index = this.index + 1;
				},
				fail: () => {},
				complete: () => {}
			});
			
		},
	}
</script>

<style lang="scss">.status{width:100%;font-size:24upx;background:#e0e0e0;text-align:center;color:#fff;margin-top:21upx;}
	page {
	  background-color: #f2f5fa;
	  box-sizing: border-box;
	}
	.container{
		  padding: 0 30rpx 30rpx 30rpx;
		  height: 100%;
	}
	.big_title {
	  font-size: 32rpx;
	  color: #1e1310;
	 font-weight: 600;
	 padding:20rpx 30rpx 10rpx 0;
	}
	.cz-box{
		border-radius: 20rpx;
		padding:30rpx;
		background: #001b4d;
		.cz-number{
			font-size: 46rpx;
			font-weight: bold;
			color:#fff;
			text-align: center;
		}
		.cz-text{
			font-size: 24rpx;
			font-weight: bold;
			color:#fff;
			text-align: center;
		}
	}
	.cz-list-cell{
		padding:30rpx;
		border-radius: 20rpx;
		box-shadow: 0px 2px 8px 3px rgba(235,235,235,0.4);;
		padding:20rpx 30rpx;
		margin-top:30rpx;
		background-color: #fff;
		.cz-triplex-list{
			height: 50rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
		}
		.cz-name{
			font-size: 28rpx;
			font-weight: 600;
			color: #1e1310;
		}
		.cz-jine{
			font-size: 28rpx;
			font-weight: 600;
			color: #c30004;
		}
		.cz-time,.cz-num{
			font-size: 24rpx;
			color:#888889;
		}
	}
</style>